<?php
class AccessHelper extends Helper{
	var $helpers = array("Session");
	var $Access;
	var $Auth;
	var $user;

	function beforeRender(){
		App::import('Component', 'Access');
		$this->Access = new AccessComponent();

		App::import('Component', 'Auth');
		$this->Auth = new AuthComponent();
		$this->Auth->Session = $this->Session;

		$this->user = $this->Auth->user();
	}

	function getMy($what){
		return !empty($this->user) && isset($this->user['User'][$what]) ? $this->user['User'][$what] : false;
	}

	function isLoggedin(){
		App::import('Component', 'Auth');
		$auth = new AuthComponent();
		$auth->Session = $this->Session;
		$user = $auth->user();
		return !empty($user);
	}
	
	function getMyRole($id){
		APP::import('Model','Group');
		$this->Group=new Group();		
		$this->data = $this->Group->find('first', array('conditions'=>array('Group.id'=>$id)));				
        return $this->data['Group']['nombre'];
	}
}
?>
